var vm = new Vue({
	el: "#app",
	data: {
		prop: "",
		Oldpass: "",
		Newpass: "",
		Renew: ""
	},
	components: {
		"popup-com": popupCom,
		"header-com": headerCom,
		"count-com": countCom
	},
	methods: {
		Submission: function () {
			const datas = Qs.stringify({
				"oldpass": this.Oldpass,
				"newpass": this.Newpass,
				"renew": this.Renew
			});
			var oldpwd = this.Oldpass;
			var newpwd1 = this.Newpass;
			var newpwd2 = this.Renew;
			var reg = /^\d{6}$/;
			if (oldpwd == "") {
				this.prop = "请输入原密码";
				return false;
			} else if (!reg.test(oldpwd)) {
				this.prop = "原密码有误，请输入6位数字原密码！";
				return false;
			}
			if (newpwd1 == "") {
				this.prop = "请输入新密码";
				return false;
			} else if (!reg.test(newpwd1)) {
				this.prop = "新密码有误，请输入6位数字新密码！";
				return false;
			}
			if (newpwd2 == "") {
				this.prop = "请输入确认密码";
				return false;
			} else if (!reg.test(newpwd2)) {
				this.prop = "确认密码有误，请重新输入确认密码！";
				return false;
			}
			if (newpwd2 !== newpwd1) {
				this.prop = "新密码与确认密码不一致！";
				return false;
			} else if (newpwd1 == oldpwd) {
				this.prop = "新密码与原密码重复，请输入新密码！";
				return false;
			}
			axios.post("/user/changepwd", datas)
				.then((res) => {
					var code = res.data.code;
					var describe = res.data.describe;
					console.log(res.data)
					switch (code) {
						case 0://密码修改成功
							window.location.href = "./user/successpass";
							break;
						case 1:
							this.prop = describe;
							break;
						case 114:
							window.location.href = "/frozen";
							break;
						case 121:
							this.prop = describe;
							break;
						case 122:
							this.prop = describe;
							break;
						case 123:
							this.prop = describe;
							break;
						case 124:
							this.prop = describe;
							break;
						case 125:
							this.prop = describe;
							break;
					}
				})
				.catch(function (error) {
					alert(error);
				})

		},
		Return: function () {
			window.location.href = "/business"
		},
		Exit: function () {
			window.location.href = "/tokens/logout"
		}

	}
});